#pragma once

namespace Utility{
	class StringConverter{
	public:
		static char* StringConverter::DuplicateCharString(const char* charString);
		/** Converts a Float to a String. */
		static std::string toString(float val, unsigned short precision = 6, 
			unsigned short width = 0, char fill = ' ', 
			std::ios::fmtflags flags = std::ios::fmtflags(0) );
		/** Converts an int to a String. */
		static std::string toString(int val, unsigned short width = 0, 
			char fill = ' ', 
			std::ios::fmtflags flags = std::ios::fmtflags(0) );
		/** Converts an unsigned long to a String. */
		static std::string toString(unsigned long val, 
			unsigned short width = 0, char fill = ' ', 
			std::ios::fmtflags flags = std::ios::fmtflags(0) );
		/** Converts a size_t to a String. */
		static std::string toString(size_t val, 
			unsigned short width = 0, char fill = ' ', 
			std::ios::fmtflags flags = std::ios::fmtflags(0) );
		/** Converts a long to a String. */
		static std::string toString(long val, 
			unsigned short width = 0, char fill = ' ', 
			std::ios::fmtflags flags = std::ios::fmtflags(0) );
		/** Converts a boolean to a String. 
		@param yesNo If set to true, result is 'yes' or 'no' instead of 'true' or 'false'
		*/
		static std::string toString(bool val, bool yesNo = false);
		/** Converts a String to a Float. 
		@returns
			0.0 if the value could not be parsed, otherwise the Real version of the String.
		*/
		template<typename type>
		static type parse(const std::string& val){
			std::istringstream str(val);
			type ret = 0;
			str >> ret;

	        return ret;
		}

		template<typename type>
		static type parse(const std::wstring& val){
			std::wistringstream str(val);
			type ret = 0;
			str >> ret;

	        return ret;
		}

		static float parseReal(const std::string& val);
		static float parseReal(const std::wstring& val);
		/** Converts a String to a whole number. 
		@returns
			0.0 if the value could not be parsed, otherwise the numeric version of the String.
		*/
		static int parseInt(const std::string& val);
		static int parseInt(const std::wstring& val);
		/** Converts a String to a whole number. 
		@returns
			0.0 if the value could not be parsed, otherwise the numeric version of the String.
		*/
		static unsigned int parseUnsignedInt(const std::string& val);
		static unsigned int parseUnsignedInt(const std::wstring& val);
		/** Converts a String to a whole number. 
		@returns
			0.0 if the value could not be parsed, otherwise the numeric version of the String.
		*/
		static long parseLong(const std::string& val);
		static long parseLong(const std::wstring& val);
		/** Converts a String to a whole number. 
		@returns
			0.0 if the value could not be parsed, otherwise the numeric version of the String.
		*/
		static unsigned long parseUnsignedLong(const std::string& val);
		static unsigned long parseUnsignedLong(const std::wstring& val);
		/** Checks the String is a valid number value. */
		static bool isNumber(const std::string& val);

		static std::wstring StringToWString(const std::string& val);
		static std::string WStringToString(const std::wstring& val);
	};
}